<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :defaults.sync="defaults"
      :page.sync="page"
      :before-open="beforeOpen"
      :search.sync="search"
      v-model="form"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <!--      <template slot="menuRight">-->
      <!--        <user-table-config :option="option" @confirm="(val) => handleSetUserConfig(val, pageCode)"></user-table-config>-->
      <!--      </template>-->
      <template slot="menuLeft">
        <el-button type="warning" size="small" icon="el-icon-download" @click="$refs.exportComp.visible = true">导出</el-button>
      </template>
      <template slot-scope="{ row }" slot="menu">
        <el-button icon="el-icon-view" size="small" type="text" v-if="permission.testDataCollection_view" @click="viewDetail(row)">详情</el-button>
      </template>
      <template slot-scope="" slot="workOrderNoSearch">
        <el-input placeholder="请选择 工单号" readonly="true" v-model="search.workOrderNo">
          <el-button slot="append" icon="el-icon-search" @click="openWorkOrderNoCommonModal"></el-button>
        </el-input>
      </template>
    </avue-crud>
    <el-dialog
      v-dragDirectives
      ref="dialog"
      title="详情"
      v-if="showDialog"
      append-to-body
      :visible.sync="showDialog"
      :close-on-click-modal="false"
      top="5vh"
      width="70%"
      @close="closeDialog"
    >
      <div class="sail-header-dialog-content">
        <div class="detail-title">基本信息：</div>
        <avue-form :option="dataDetailOption" :table-loading="loading" v-model="dataDetail">
          <template slot="attachments">
            <div class="img-list">
              <div style="margin: 5px 10px; display: flex; flex-direction: column" v-for="(item, index) in dataDetail.imageList || []" :key="index">
                <img style="width: 100px; height: 100px" :src="item.link" @click="openPreview('0', item.link)" />
                <button type="button" :class="`el-button el-button--text el-button--small downLoadFile${index}`" @click="handleDownload(item.link)">
                  <i class="el-icon-download"></i><span>下载</span>
                </button>
              </div>
            </div>
          </template>
          <template slot="repairName">
            <el-input
              v-if="dataDetail.productHandlingResultList"
              type="textarea"
              disabled
              :autosize="{ minRows: 2, maxRows: 4 }"
              v-model="dataDetail.productHandlingResultList.map((list) => list.resultName).join('；')"
            >
            </el-input>
          </template>
        </avue-form>
        <div class="detail-title" v-if="dataDetail.mroRefuelingMaterialList && dataDetail.mroRefuelingMaterialList.length > 0">换料类型：原材料</div>
        <table border="1" cellspacing="0" cellpadding="0" style="width: 100%" v-if="dataDetail.mroRefuelingMaterialList && dataDetail.mroRefuelingMaterialList.length > 0">
          <tbody style="border: 1px solid #ebeef5">
            <tr style="height: 40px">
              <th class="tdStyle2" colspan="3" style="padding: 0 80px">序列号</th>
              <th class="tdStyle2">维修位号</th>
              <th class="tdStyle2">录入类型</th>
              <th class="tdStyle2">物料包装条码</th>
              <th class="tdStyle2">物料编码</th>
              <th class="tdStyle2">物料名称</th>
              <th class="tdStyle2">供应商</th>
              <th class="tdStyle2">物料批次</th>
              <th class="tdStyle2">品牌</th>
              <th class="tdStyle2">维修用量</th>
            </tr>
            <template v-if="dataDetail.mroRefuelingMaterialList && dataDetail.mroRefuelingMaterialList.length > 0">
              <tr style="height: 40px" v-for="item in dataDetail.mroRefuelingMaterialList">
                <td class="tdStyle3" colspan="3" style="padding: 0 0px">{{ item.productSn }}</td>
                <td class="tdStyle3">{{ item.locationCode }}</td>
                <td class="tdStyle3">{{ item.inputType == 0 ? '无条码' : '有条码' }}</td>
                <td class="tdStyle3">{{ item.newSn }}</td>
                <td class="tdStyle3">{{ item.newPartNo }}</td>
                <td class="tdStyle3">{{ item.newPartName }}</td>
                <td class="tdStyle3">{{ item.newVendorCode }}</td>
                <td class="tdStyle3">{{ item.newPartLot }}</td>
                <td class="tdStyle3">{{ item.newPartBrand }}</td>
                <td class="tdStyle3">{{ item.quantity }}</td>
              </tr>
            </template>
            <tr v-else>
              <td colspan="17" class="detail-title noData">暂无数据</td>
            </tr>
          </tbody>
        </table>
        <div class="detail-title" v-if="dataDetail.mroRefuelingComponentList && dataDetail.mroRefuelingComponentList.length > 0">换料类型：子件组装料</div>
        <table border="1" cellspacing="0" cellpadding="0" style="width: 100%" v-if="dataDetail.mroRefuelingComponentList && dataDetail.mroRefuelingComponentList.length > 0">
          <tbody style="border: 1px solid #ebeef5">
            <tr style="height: 40px">
              <th class="tdStyle2" colspan="3" style="padding: 0 80px">序列号</th>
              <th class="tdStyle2">维修位号</th>
              <th class="tdStyle2">旧子件序列号</th>
              <th class="tdStyle2">新子件序列号</th>
              <th class="tdStyle2">产品编码</th>
              <th class="tdStyle2">产品名称</th>
              <th class="tdStyle2">产品型号</th>
              <th class="tdStyle2">维修用量</th>
            </tr>
            <template v-if="dataDetail.mroRefuelingComponentList && dataDetail.mroRefuelingComponentList.length > 0">
              <tr style="height: 40px" v-for="item in dataDetail.mroRefuelingComponentList">
                <td class="tdStyle3" colspan="3" style="padding: 0 0px">{{ item.productSn }}</td>
                <td class="tdStyle3">{{ item.locationCode }}</td>
                <td class="tdStyle3">{{ item.oldSn }}</td>
                <td class="tdStyle3">{{ item.newSn }}</td>
                <td class="tdStyle3">{{ item.newPartNo }}</td>
                <td class="tdStyle3">{{ item.newPartName }}</td>
                <td class="tdStyle3">{{ item.newPartModel }}</td>
                <td class="tdStyle3">{{ item.quantity }}</td>
              </tr>
            </template>
            <tr v-else>
              <td colspan="17" class="detail-title noData">暂无数据</td>
            </tr>
          </tbody>
        </table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="showDialog = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <common-modal-template ref="commonModalTemplate" :option="tableOption" @getSelectedRows="getSelectedRows" :key="timer" @newKey="newKey"> </common-modal-template>
    <export-comp ref="exportComp" page-api-url="mes-product/mro/centerproduct/repair/report/page" :option="option" :page="page" :query="query" file-name="维修记录">
    </export-comp>
  </basic-container>
</template>

<script>
import { getList } from '@/api/report/maintenance-record-query';
import { mapGetters } from 'vuex';
import CommonModalTemplate from '@/components/common-modal-template/common-modal-template.vue';
import { getList as getRepairSiteList } from '@/api/repair/repairSite';
import { getList as getFailureConfigList } from '@/api/repair/failureconfig';
import exportComp from '@/components/export-comp';
import userTableConfig from '@/components/user-table-config';
import userConfig from '@/mixins/userConfig';
export default {
  name: 'ReportMaintenanceRecordQuery',
  components: {
    CommonModalTemplate,
    exportComp,
    userTableConfig
  },
  mixins: [userConfig()],
  filters: {
    handleRefuelingType(type) {
      switch (type) {
        case 'BOM':
          return 'BOM物料';
        case 'PACKING':
          return '包装物料批次';
        case 'COMPONENT':
          return '子件组装料';
        default:
          break;
      }
    }
  },
  data() {
    return {
      pageCode: 'MAINTENCE_RECORD_QUERY',
      timer: new Date().getTime(), //不同内容使用同一个模态框结构，key值不同需要重新请求渲染数据，否则会请求到上一个使用的数据内容
      modalName: '', //打开公用模态框名称
      tableOption: {}, //公用模态框配置信息
      form: {},
      defaults: {},
      query: {},
      dataDetail: {},
      data: [],
      showDialog: false,
      loading: true,
      page: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      search: {},
      selectionList: [],
      reloadData: [],
      option: {
        height: 'calc(100vh - 485px)',
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchSpan: 6,
        searchMenuSpan: 24,
        labelWidth: 100,
        border: true,
        index: true,
        editBtn: false,
        viewBtn: false,
        selection: true,
        delBtn: false,
        addBtn: false,
        dialogClickModal: false,
        indexLabel: '序号',
        searchMenuPosition: 'right',
        searchLabelWidth: 120,
        menuWidth: 100,
        columnBtn: false,
        column: [
          {
            label: '不良登记类型',
            prop: 'objectType',
            search: true,
            searchOrder: 2,
            type: 'select',
            dicData: [
              {
                label: '产品序列号',
                value: 'PRODUCT'
              },
              {
                label: '工单号',
                value: 'WORKORDER'
              }
              // {
              //   label: '包装条码',
              //   value: 'PACKING'
              // },
              // {
              //   label: '载具',
              //   value: 'CARRIER'
              // }
            ]
          },
          {
            label: '序列号',
            prop: 'productSequenceNumber',
            search: true,
            searchOrder: 3
          },
          {
            label: '外部序列号',
            prop: 'outSequenceNumber',
            search: true,
            searchOrder: 10
          },

          {
            label: '工单号',
            prop: 'workOrderNo',
            search: true,
            searchOrder: 1
          },
          {
            label: '产品编码',
            prop: 'partNo'
          },
          {
            label: '产品名称',
            prop: 'partName'
          },
          {
            label: '产品型号',
            prop: 'partModel'
          },
          {
            label: '客户编码',
            prop: 'partnerCode',
            search: true,
            searchOrder: 16
          },
          {
            label: '不良数',
            prop: 'quantity'
          },
          {
            label: '已维修次数',
            prop: 'repairedTimes'
          },
          {
            label: '登记产线',
            prop: 'lineName',
            search: true,
            type: 'select',
            searchOrder: 8,
            dicUrl: '/api/mes-product/productionline/page?size=10000&current=1',
            props: {
              label: 'name',
              value: 'name'
            },
            dicFormatter: (data) => {
              return data.data.records;
            }
          },
          {
            label: '登记工序',
            prop: 'fromRouteName'
          },
          {
            label: '登记工位',
            prop: 'fromStationName'
          },
          {
            label: '不良登记时间',
            prop: 'registryDate'
          },
          {
            label: '不良现象',
            prop: 'failureName'
          },
          {
            label: '不良类型',
            prop: 'failureTypeName'
          },
          {
            label: '不良原因大类',
            prop: 'mainCauseName'
          },
          {
            label: '不良原因小类',
            prop: 'subCauseName'
          },

          {
            label: '维修员',
            prop: 'operatorName',
            search: true,
            searchOrder: 4
          },
          {
            label: '维修动作',
            prop: 'repairName',
            search: true,
            searchOrder: 6,
            type: 'select',
            dicUrl: '/api/mes-product/mro/dict/list?dictType=ACTION',
            props: {
              label: 'code',
              value: 'code'
            }
          },
          {
            label: '维修说明',
            prop: 'repairDesc'
          },
          // {
          //   label: '维修时间',
          //   prop: 'repairTime'
          // },
          {
            label: '维修时长',
            prop: 'repairDurationFormat'
          },
          {
            label: '出维修确认人',
            prop: 'repairOutConfirmName'
          },
          {
            label: '出维修确认时间',
            prop: 'repairOutConfirmTime',
            width: 130,
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss'
          },

          {
            label: '出维修确认结果',
            prop: 'repairOutConfirmResult',
            search: true,
            searchOrder: 7,
            type: 'select',
            dicData: [
              {
                label: '返回重修',
                value: 'REMRO'
              },
              {
                label: '出维修',
                value: 'SUCCESS'
              },
              {
                label: '报废',
                value: 'SCRAP'
              }
            ]
          },
          {
            label: '出维修意见说明',
            prop: 'repairOutRemark'
          },

          {
            label: '不良判定人员',
            prop: 'judgeUserName',
            search: true,
            searchOrder: 4
          },
          {
            label: '不良判定时间',
            prop: 'judgeTime',
            search: true,
            searchOrder: 13,
            searchSpan: 6,
            searchType: 'datetimerange',
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间'
          },
          {
            label: '维修时间',
            prop: 'repairTime',
            search: true,
            searchOrder: 13,
            searchSpan: 6,
            searchType: 'datetimerange',
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间'
          },
          {
            label: '维修类型',
            prop: 'repairType',
            type: 'select',
            search: true,
            searchOrder: 5,
            dicData: [
              {
                label: '在线维修',
                value: 'ONLINEREPAIR'
              },
              {
                label: '离线维修',
                value: 'OFFLINEREPAIR'
              }
            ]
          },
          {
            label: '维修工序',
            prop: 'repairRouteName'
          },
          {
            label: '维修位号',
            prop: 'locationCode'
          },
          {
            label: '是否换料',
            prop: 'isRefueling',
            type: 'select',
            search: true,
            searchOrder: 11,
            dicData: [
              {
                label: '是',
                value: true
              },
              {
                label: '否',
                value: false
              }
            ],
            control: (val, form) => {
              return {
                refuelingType: {
                  disabled: !val
                }
              };
            }
          },
          {
            label: '换料类型',
            prop: 'refuelingType',
            type: 'select',
            search: true,
            searchOrder: 12,
            dicData: [
              {
                label: 'BOM物料',
                value: 'BOM'
              },
              {
                label: '包装批次物料',
                value: 'PACKING'
              },
              {
                label: '子件组装料',
                value: 'COMPONENT'
              }
            ]
          },
          // {
          //   label: '换料位号',
          //   prop: 'refuelTrackNo'
          // },
          {
            label: '维修用料编码',
            prop: 'refuelPartNo'
          },
          {
            label: '维修用料名称',
            prop: 'refuelPartName'
          },

          {
            label: '维修用料数量',
            prop: 'refuelQuantity'
          }
        ]
      },
      dataDetailOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: '150',
        detail: true,
        column: [
          {
            label: '工单号',
            prop: 'workOrderNo',
            disabled: true
          },
          {
            label: '车间',
            prop: 'workshopName',
            disabled: true
          },
          {
            label: '产线',
            prop: 'lineName',
            disabled: true
          },
          {
            label: '产品编码',
            prop: 'partNo',
            disabled: true
          },
          {
            label: '产品名称',
            prop: 'partName',
            disabled: true
          },

          {
            label: '产品型号',
            prop: 'partModel',
            disabled: true
          },
          {
            label: '序列号',
            prop: 'productSequenceNumber',
            disabled: true
          },
          {
            label: '外部序列号',
            prop: 'outSequenceNumber',
            disabled: true
          },
          {
            label: '维修位号',
            prop: 'locationCode',
            disabled: true
          },
          {
            label: '登记类型',
            prop: 'objectType',
            disabled: true,
            type: 'select',
            dicData: [
              {
                label: '产品序列号',
                value: 'PRODUCT'
              },
              {
                label: '工单号',
                value: 'WORKORDER'
              }
            ]
          },
          {
            label: '客户编码',
            prop: 'partnerCode',
            search: true,
            searchOrder: 16
          },
          {
            label: '不良数',
            prop: 'quantity',
            disabled: true
          },
          {
            label: '不良来源',
            prop: 'registrySource',
            disabled: true,
            type: 'select',
            dicData: [
              {
                label: '自动',
                value: 'AUTO'
              },
              {
                label: '手动',
                value: 'MANUAL'
              }
            ]
          },
          {
            label: '当前所处工序',
            prop: 'currentRouteName',
            disabled: true
          },
          {
            label: '登记产线',
            prop: 'failureLineName',
            disabled: true
          },
          {
            label: '登记工序',
            prop: 'fromRouteName',
            disabled: true
          },
          {
            label: '登记工位',
            prop: 'fromStationName',
            disabled: true
          },
          {
            label: '不良登记时间',
            prop: 'registryDate'
          },
          {
            label: '不良现象代码',
            prop: 'failureCode',
            disabled: true
          },
          {
            label: '不良现象',
            prop: 'failureName',
            disabled: true
          },
          {
            label: '不良类型',
            prop: 'failureTypeName'
          },
          {
            label: '不良登记人员',
            prop: 'registryByName',
            disabled: true
          },
          {
            label: '不良登记时间',
            prop: 'registryDate',
            disabled: true
          },
          {
            label: '不良判定人员',
            prop: 'judgeByName',
            disabled: true
          },
          {
            label: '不良判定时间',
            prop: 'judgeTime',
            disabled: true
          },
          {
            label: '不良原因大类',
            prop: 'mainCauseName',
            disabled: true
          },
          {
            label: '不良原因小类',
            prop: 'subCauseName',
            disabled: true
          },
          {
            label: '维修类型',
            prop: 'repairType',
            type: 'select',
            disabled: true,
            dicData: [
              {
                label: '在线维修',
                value: 'ONLINEREPAIR'
              },
              {
                label: '离线维修',
                value: 'OFFLINEREPAIR'
              }
            ]
          },
          {
            label: '维修员',
            prop: 'operatorName',
            disabled: true
          },
          {
            label: '维修动作',
            prop: 'repairName',
            type: 'select',
            dicUrl: '/api/mes-product/mro/dict/list?dictType=ACTION',
            props: {
              label: 'code',
              value: 'code'
            },
            // type: 'textarea',
            // maxRows: 3,
            // minRows: 3,
            // span: 24,
            disabled: true,
            formslot: true
          },
          {
            label: '维修说明',
            prop: 'repairDesc',
            disabled: true
          },
          {
            label: '维修时间',
            prop: 'repairTime',
            disabled: true
          },
          {
            label: '维修时长',
            prop: 'repairDurationFormat'
          },
          {
            label: '出维修确认结果',
            prop: 'repairOutConfirmResult',
            type: 'select',
            disabled: true,
            dicData: [
              {
                label: '返回重修',
                value: 'REMRO'
              },
              {
                label: '出维修',
                value: 'SUCCESS'
              },
              {
                label: '报废',
                value: 'SCRAP'
              }
            ]
          },
          {
            label: '出维修意见说明',
            prop: 'repairOutRemark',
            disabled: true
          },
          {
            label: '维修图片',
            prop: 'attachments',
            span: 24,
            formslot: true
          }
        ]
      }
    };
  },
  computed: {
    ...mapGetters(['permission']),
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(',');
    }
  },
  created() {
    // let startDate = this.$moment(new Date()).format('YYYY-MM-DD');
    // let endDate = this.$moment(new Date()).format('YYYY-MM-DD');
    // startDate = startDate + ' ' + '00:00:00';
    // endDate = endDate + ' ' + '23:59:59';
    // this.$set(this.search, 'createTimes', [startDate, endDate]);
    // this.query.createTimes = this.search.createTimes;
  },
  mounted() {
    this.$nextTick(() => {
      this.$structuralSplit();
      let urlQuery = this.$route.query;
      if (urlQuery && urlQuery.sequenceNumber) {
        this.search.productSequenceNumber = decodeURIComponent(urlQuery.sequenceNumber);
        this.search.objectType = decodeURIComponent(urlQuery.objectType);
        this.search.createTimes = ['', ''];
      }
    });
    const repairCenterName = this.findObject(this.option.column, 'repairCenterName');
    repairCenterName.dicData = [];
    getRepairSiteList(1, 10000, {})
      .then((res) => {
        repairCenterName.dicData = this._get(res, 'data.data.records', []);
        repairCenterName.dicData = this._map(repairCenterName.dicData, (item) => {
          return {
            label: item.name,
            value: item.code
          };
        });
      })
      .catch((err) => {
        repairCenterName.dicData = [];
      });
    const repairName = this.findObject(this.option.column, 'repairName');
    repairName.dicData = [];
    getFailureConfigList(1, 10000, { dictType: 'ACTION' })
      .then((res) => {
        repairName.dicData = this._get(res, 'data.data.records', []);
        repairName.dicData = this._map(repairName.dicData, (item) => {
          return {
            label: item.name,
            value: item.name
          };
        });
      })
      .catch((err) => {
        repairName.dicData = [];
      });
  },
  methods: {
    initData(tenantId) {},
    beforeOpen(done, type) {
      if (['edit', 'view'].includes(type)) {
        getDetail(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
      done();
    },
    searchReset() {
      this.query = {};
      this.search = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      // if (params.createTimes) {
      //   params.confirmStartTime = params.createTimes[0];
      //   params.confirmEndTime = params.createTimes[1];
      //   delete params.createTimes;
      // }
      // if (params.repairCenterName) {
      //   params.repairCenterCode = params.repairCenterName;
      //   delete params.repairCenterName;
      // }
      // if (params.repairHandlingResult) {
      //   params.handlingResult = params.repairHandlingResult;
      //   delete params.repairHandlingResult;
      // }
      if (params.judgeTime) {
        params.judgeStartTime = params.judgeTime[0];
        params.judgeEndTime = params.judgeTime[1];
        delete params.judgeTime;
      }
      if (params.repairTime) {
        params.repairStartTime = params.repairTime[0];
        params.repairEndTime = params.repairTime[1];
        delete params.repairTime;
      }
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      // if (this.query.createTimes) {
      //   this.query.confirmStartTime = this.$moment(this.query.createTimes[0]).format('YYYY-MM-DD HH:mm:ss');
      //   this.query.confirmEndTime = this.$moment(this.query.createTimes[1]).format('YYYY-MM-DD HH:mm:ss');
      //   delete this.query.createTimes;
      // }
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records || [];
        this.data.forEach((item) => {
          item.failureLineName = item.lineName;
        });
        this.loading = false;
        this.selectionClear();
        delete this.query.createTimes;
        this.search.createTime = [];
      });
    },
    // 下载
    openDownload(row) {
      if (row.fileUrl) {
        this.globalStartLoad('文件下载中，请稍后...');
        downloadFileByUrl(row.fileUrl, row.fileName);
        this.globalEndLoad();
      }
    },
    openPreview(index = 0, link) {
      this.$ImagePreview([{ url: link }], index, {
        closeOnClickModal: false
      });
    },
    handleDownload(link) {
      window.open(`${link}`);
    },
    viewDetail(row) {
      this.showDialog = true;
      this.dataDetail = row;
      this.dataDetail.mroRefuelingMaterialList = this._map(this._get(row, 'mroRefuelingMaterialList', []), (item) => {
        return item;
      });
      this.dataDetail.mroRefuelingComponentList = this._map(this._get(row, 'mroRefuelingComponentList', []), (item) => {
        return item;
      });
      console.log(this.dataDetail.mroRefuelingMaterialList, 'this.dataDetail.mroRefuelingMaterialList');
      console.log(this.dataDetail.mroRefuelingComponentList, 'this.dataDetail.mroRefuelingComponentList');
    },
    /**
     * 打开操作人员列表模态框
     */
    openUserCommonModal() {
      this.modalName = 'userModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择操作人（双击进行选择）',
        url: '/api/blade-system/user/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '登录账号',
            prop: 'account',
            search: true,
            display: false
          },
          {
            label: '所属租户',
            prop: 'tenantName',
            slot: true,
            display: false
          },
          {
            label: '用户姓名',
            prop: 'realName',
            search: true,
            display: false
          },
          {
            label: '所属角色',
            prop: 'roleName',
            slot: true,
            display: false
          },
          {
            label: '所属部门',
            prop: 'deptName',
            slot: true,
            display: false
          },
          {
            label: '用户平台',
            prop: 'userTypeName',
            slot: true,
            display: false
          },
          {
            label: '用户平台',
            type: 'select',
            dicUrl: '/api/blade-system/dict/dictionary?code=user_type',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            dataType: 'number',
            search: true,
            hide: true,
            display: false,
            prop: 'userType',
            rules: [
              {
                required: true,
                message: '请选择用户平台',
                trigger: 'blur'
              }
            ]
          }
        ]
      };
    },
    openWorkOrderNoCommonModal() {
      this.modalName = 'workOrderNoModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择操作人员（双击进行选择）',
        url: '/api/mes-product/work-order/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '生产订单',
            prop: 'productionOrderNo',
            search: true
          },
          {
            label: '生产工单',
            prop: 'orderNo',
            search: true
          },
          {
            label: '工单类型',
            prop: 'orderType',
            type: 'select'
          },
          {
            label: '工单数量',
            prop: 'planQuantity'
          },
          {
            label: '产品编码',
            prop: 'partNo'
          },
          {
            label: '产品名称',
            prop: 'partName'
          },
          {
            label: 'BOM版本',
            prop: 'bomVersion'
          },
          {
            label: '派工产线',
            prop: 'productionLineName'
          },
          {
            label: '计划开始时间',
            prop: 'planStartDate'
          },
          {
            label: '计划结束时间',
            prop: 'planEndDate'
          },
          {
            label: '制定人',
            prop: 'creatorName'
          },
          {
            label: '状态',
            prop: 'status',
            type: 'select',
            dicData: [
              {
                label: '待排程',
                value: 1
              },
              {
                label: '待生产',
                value: 2
              },
              {
                label: '生产中',
                value: 3
              },
              {
                label: '完工',
                value: 4
              },
              {
                label: '锁定',
                value: 5
              },
              {
                label: '强制完工',
                value: 6
              }
            ]
          },
          {
            label: '备注',
            prop: 'remark'
          }
        ]
      };
    },
    openPartNoCommonModal() {
      this.modalName = 'partNoModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择产品信息（双击进行选择）',
        url: '/api/mes-admin/part-master/page?semifinished=true',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '类型',
            prop: 'categoryId',
            search: true,
            type: 'tree',
            dicUrl: '/api/mes-admin/part-category/tree',
            props: {
              label: 'title',
              value: 'id'
            }
          },
          {
            label: '编码',
            prop: 'partNo',
            search: true
          },
          {
            label: '名称',
            prop: 'name',
            search: true
          },
          {
            label: '型号',
            prop: 'partModel'
          },
          {
            label: '描述',
            prop: 'description'
          },
          {
            label: '版本',
            prop: 'revision'
          }
        ]
      };
    },
    newKey() {
      this.timer = new Date().getTime();
    },
    /**
     * 获取选择的模态框行数据
     */
    getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'userModal':
          this.search.operator = this._get(rowData, 'id', '');
          this.search.operatorName = this._get(rowData, 'realName', '');
          break;
        case 'workOrderNoModal':
          this.search.workOrderId = this._get(rowData, 'id', '');
          this.search.workOrderNo = this._get(rowData, 'orderNo', '');
          break;
        case 'partNoModal':
          this.search.partId = this._get(rowData, 'id', '');
          this.search.partNo = this._get(rowData, 'partNo', '');
          break;
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.img-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.detail-title {
  font-weight: bold;
  font-size: 14px;
  margin: 10px 0;
}
.detail-title.noData {
  text-align: center;
}
.tdStyle2 {
  white-space: nowrap;
  background: #fafafa;
  font-weight: 700;
  padding: 0 10px;
}
.tdStyle3 {
  text-align: center;
}
</style>
